package day06;

import jakarta.servlet.FilterChain;
import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpFilter;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import java.io.IOException;

public class CharsetFilter extends HttpFilter {

    @Override
    protected void doFilter(HttpServletRequest request, HttpServletResponse response, FilterChain chain) throws IOException, ServletException {

//        request.setCharacterEncoding("utf-8");

        String encoding=getFilterConfig().getInitParameter("encoding");
        request.setCharacterEncoding(encoding);

        chain.doFilter(request,response);
    }
}
